package br.com.fiap.trabalho.junit;

import java.util.List;

import org.junit.Test;

import br.com.fiap.trabalho.dao.StudioDAO;
import br.com.fiap.trabalho.entity.Studio;
import br.com.fiap.trabalho.factory.DaoFactory;

public class JDBCStudioDAOTestMetric extends DAOtest{
	
	private static StudioDAO studioDAO = DaoFactory.getDaoFactory(DaoFactory.JDBC).getStudioDAO();
	
	public void createEntity() {

		for(int i = 0; i < numberOfIteractions; i++){
			
			Studio studio = new Studio();
			studio.setName("Studio de teste"+i);
			
			studioDAO.createStudio(studio);
		}

		System.out.println("Tempo para criar entidades Studio JDBC: ");
	}

	public void listEntity() {

		studioDAO.selectStudios(numberOfIteractions);
		
		System.out.println("Tempo para Listar entidades Studio JDBC: ");
		
	}
	
	public void updateEntity() {

		List<Studio> studiosForUpdate = studioDAO.selectStudios(numberOfIteractions);
		
		int i = 0;
		for(Studio studio : studiosForUpdate){
			
			studio.setName("Studio de teste"+i);
			
			studioDAO.createStudio(studio);
			i++;
		}
		
		System.out.println("Tempo para Update entidades Studio JDBC: ");
	}
	
	@Test
	public void getcategoriesWithMovie() {
		
		List<Studio> studiosWithMovie = studioDAO.selectStudios(numberOfIteractions);

		for(Studio studio : studiosWithMovie){
			
			studioDAO.selectStudioByName(studio.getName());
		}
		
		System.out.println("Tempo para Listar Studio with Movie JDBC: ");
	}
}
